<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')

			// #ifdef MP-WEIXIN
			console.log(this.vuex_token)
			if (!this.vuex_token) {
				const _that = this
				uni.getUserInfo({
					provider: 'weixin',
					success: function(result) {
						_that.fStoreUserInfo(result.userInfo)
					},
					fail: function() {
						_that.$u.route({
							url: "pages/authorize",
							type: 'redirectTo'
						})
						uni.setNavigationBarTitle({
							title: '授权信息'
						});
					}
				});
			}
			// #endif
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			fStoreUserInfo(userInfo) {
				const _that = this
				uni.login({
					provider: 'weixin',
					success: function(loginRes) {
						_that.$u.api.login(loginRes.code).then(res => {
							_that.$u.vuex('vuex_token', res.data)
						})
					}
				});
			}
		}
	}
</script>


<style lang="scss">
	@import "uview-ui/index.scss";
</style>
